﻿using Domain.Entities;
using Domain.IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Application.LogApp
{
    public class LogAppService : ILogAppService
    {

        //用户管理仓储接口
        private readonly ILogRepository _repository;

        /// <summary>
        /// 构造函数 实现依赖注入
        /// </summary>
        /// <param name="LogRepository">仓储对象</param>
        public LogAppService(ILogRepository LogRepository)
        {
            _repository = LogRepository;
        }

        public Log GetById(Int32 id)
        {
            return _repository.GetById(id);
        }

        public List<Log> GetAll(string parentid)
        {
            return _repository.GetAll(parentid).ToList();
        }
        public List<Log> GetAll(string SearchKeyWords, int userid)
        {
            return _repository.GetAll(SearchKeyWords, userid).ToList();
        }

        public List<Log> GetPageList(int userid, string SearchKeyWords, int PageSize, int PageCurrent, string OrderField, bool OrderDirection = true)
        {

            return _repository.GetPageList(userid, SearchKeyWords, PageSize, PageCurrent, OrderField, OrderDirection).ToList();
        }
        public bool AddOrUpdate(Log model)
        {
            return _repository.AddOrUpdate(model);
        }

        public bool Add(DateTime time, string IP, string userid, int operation, string remark)
        {
            Log model = new Log() {
                Createtime=time,
                Log_ip=IP,
                Log_userid=userid,
                Log_operation=operation,
                Log_remark=remark
            };
            return _repository.AddOrUpdate(model);
        }
    }
}
